package com.felix.algorithms.easy;

/**
 * ExcelSheetColumnNumber
 *
 * @author xuejinhua
 * @date 2018/9/20 10:14
 */
public class ExcelSheetColumnNumber {

    public static int solution(String s) {
        char[] chars = s.toCharArray();
        int sum = 0;
        int length = chars.length;
        for (int i = 0; i < length; i++) {
            sum += (chars[i] - 64) * Math.pow(26, length - i - 1);
        }
        return sum;
    }

    public static void main(String[] args) {
        System.out.println(solution("ZY"));
    }

}
